function loadData(dataType) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        if (Math.random() > 0.5) {
          const data = `Loaded data of type ${dataType}`;
          resolve(data);
        } else {
          const errorMessage = `Failed to load data of type ${dataType}`;
          reject(errorMessage);
        }
      }, 1000);
    });
  }
  
  loadData('typeA')
   .then(dataA => {
      console.log(dataA);
      return loadData('typeB');
    })
   .then(dataB => {
      console.log(dataB);
    })
   .catch(error => {
      console.error(error);
    });